<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../vue.js"></script>
</head>
<body>

<div id="app">

    <ul>
        <li is="todo-item"
            v-for="(item, index) in items"
            :title="item.title"
            @remove="items.splice(index, 1)"
            :key="item.id"></li>
    </ul>

    <input type="text" v-model="inputText" @keyup.enter="pushArray">


</div>


<script>
    Vue.component('todo-item', {
        template: '<li>{{title}} &nbsp;&nbsp;&nbsp;&nbsp;<button @click="$emit(\'remove\')">X</button></li>',
        props: ['title']
    })

    var app = new Vue({
        el: "#app",
        data: {
            items: [
                {id: 1, title: "ready material"},
                {id: 2, title: "create face"}
            ],
            sequenceOfItemId: 3,
            inputText: ""
        },
        methods: {
            pushArray: function () {
                var inputText = this.inputText;
                if (inputText.trim() === "") {
                    return;
                }
                this.items.push({id: this.sequenceOfItemId++, title: this.inputText});
                this.inputText = "";
            }
        }
    })

</script>

</body>
</html>